package com.bwie.controller;
import com.bwie.pojo.Brand;
import com.bwie.pojo.Type;
import com.bwie.service.BrandService;
import com.bwie.service.impl.BrandServiceImpl;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.multipart.MultipartFile;

/**
* 品牌表(tb_brand)表控制层
*
* @author xxxxx
*/
@RestController
@RequestMapping("/brand/brand")
public class BrandController {
/**
* 服务对象
*/
    @Autowired
    private BrandService brandService;

    @ApiOperation("品牌列表")
    @PostMapping("/brandList")
    public R brandList(@RequestBody PageInfoVo pageInfoVo){
        return brandService.brandList(pageInfoVo);
    }

    @ApiOperation("开关状态")
    @PostMapping("/updateStatus")
    public R updateStatus(@RequestBody Brand brand){
        return brandService.updateStatus(brand);
    }

    @ApiOperation("添加")
    @PostMapping("/addBrand")
    public R addBrand(@RequestBody Brand brand){
        return brandService.addBrand(brand);
    }

    @ApiOperation("分类树")
    @PostMapping("/typeTreeList")
    public R typeTreeList(@RequestBody PageInfoVo pageInfoVo){
        return brandService.typeTreeList(pageInfoVo);
    }

    /**
     * 添加类型
     * @param type
     * @return
     */
    @PostMapping("/addType")
    public R addType(@RequestBody @Validated Type type){
        return  brandService.addType(type);
    }

    /**
     * 商品图片上传
     * @param file
     * @return
     */
    @PostMapping("/uploadTypeImage")
    public R uploadTypeImage(@RequestPart("file") MultipartFile file){
        return brandService.uploadTypeImage(file);
    }

    @ApiOperation("品牌列表")
    @PostMapping("/getbrandList")
    public R getbrandList(){
        return brandService.getbrandList();
    }

    @ApiOperation("type列表")
    @PostMapping("/gettypeList")
    public R gettypeList(){
        return brandService.gettypeList();
    }

}
